/*
 Created by Moonbreeze on 2015/12/17.

 this class represent the JVM heap which use to store every Object in memory
 we use a map to store the Object and its ObjectID
*/

#ifndef CUSTOMJVM_OBJECTHEAP_H
#define CUSTOMJVM_OBJECTHEAP_H

#include <string>
#include <map>
#include "types.h"
#include "ClassHeap.h"

class ObjectHeap{
public:
    ObjectHeap(void);
    virtual ~ObjectHeap();

    virtual Variable* GetObjectPointer(Object object);
    Object CreateObject(JavaClass* pClass);
    Object CreateStringObject(std::string pStrValue,ClassHeap* pClassHeap);
    Object CreateNewArray(u1 type,i4 count);
    bool CreateObjectArray(JavaClass* pClass,u4 count,Object& object);

private:
    std::map<int,Variable*> m_ObjectMap;
    u4 m_nNextObjectID;
};
#endif //CUSTOMJVM_OBJECTHEAP_H
